import cTitle from "components/title";

export default {
  data() {
    return {
      toi: this.fun.getKeyByI(),
      list: [],
      popupSpecs: false,
      //提现方式
      pay_way_name:"",
      //打款金额
      actual_amounts: 0,
      //打款手续费
      actual_poundage: 0,
      //提款金额
      amounts: 0,
      //类型
      type_name: "",
      withdraw_sn: "",
      //统计佣金
      commission_amount: 0,
      //统计方式
      formula: 0,
      //获得佣金
      commission: 0,
      //比例
      commission_rate: 0,
      incomes: [],
      created_at: "",
      poundage_name: "",//手续费字样

      amount_detail:{
        data:[],
        current_page:1,
        last_page:1,
        isLoadMore:true
      },

      show:false,
      actual_servicetax: 0,	//提现劳务税
      reject_reason:"" //备注
    };
  },
  methods: {
    //初始化
    init() {
      this.withdraw_sn = "";
      this.type_name = "";
      this.amounts = "";
      this.created_at = "";
      this.actual_poundage = "";
      this.actual_amounts = "";
      //自定义手续费字段
      this.poundage_name = this.fun.initMailLanguage().income.poundage_name;
    },
  async   scrollHandle(){
      if(this.amount_detail.current_page>=this.amount_detail.last_page){
        return;
      }
      if(this.amount_detail.isLoadMore){
        this.amount_detail.isLoadMore = false;
        let page = this.amount_detail.current_page + 1;
        let {result,data,msg} = await $http.get("finance.withdraw.incomelist",{id:this.$route.params.record_id,page})
        this.amount_detail.isLoadMore = true;
        if(result==0)return this.$toast(msg);
        this.amount_detail.data = this.amount_detail.data.concat(data.data);
        this.amount_detail.current_page = data.current_page;
        this.amount_detail.last_page=data.last_page;
      }
    },
    async show_detail(){
      this.show=true;
      let {result,data,msg} = await $http.get("finance.withdraw.incomelist",{id:this.$route.params.record_id})
      if(result==0)return this.$toast(msg);
      this.amount_detail.data = data.data;
      this.amount_detail.current_page = data.current_page;
      this.amount_detail.last_page=data.last_page;

      if(this.$refs['popupRoot']){
        let dom = this.$refs['popupRoot'].$el;
        dom.addEventListener("scroll",this.scrollHandle)
      }
    },

    //获取数据
    getData() {
      let that = this;
      $http
        .get(
          "finance.withdraw.withdraw-info",
          {
            id: this.$route.params.record_id,
            i: this.fun.getKeyByI(),
            type: this.fun.getTyep()
          },
          ""
        )
        .then(
          function(response) {
            if (response.result == 1) {
              var mydata = response.data;

              //提现方式
              that.pay_way_name = mydata.pay_way_name;
              //打款手续费
              that.actual_poundage = mydata.actual_poundage;
              //提款金额
              that.amounts = mydata.amounts;
              //类型
              that.type_name = mydata.type_name;
              that.withdraw_sn = mydata.withdraw_sn;
              //that.incomes = mydata.incomes; 暂时取消
              that.created_at = mydata.created_at;
              that.actual_amounts = mydata.actual_amounts;
              that.actual_servicetax = mydata.actual_servicetax;
              that.reject_reason = mydata.reject_reason;
            } else {
              console.log(response.msg);
            }
          },
          function(response) {
            console.log(response);
          }
        );
    },

    //返回
    goto() {
      window.history.go(-1);
    },

    //筛选
    screen() {
      this.popupSpecs = true;
    }
  },

  activated() {
    //获取数据
    this.init();
    this.getData();
    this.toi = this.fun.getKeyByI();
    this.fun.setWXTitle(this.fun.initWithdrawal() + "详情");
  },
  components: { cTitle }
};
